<template>
  <div class="single-bar" ref="singleBar">SingleBarChart</div>
</template>

<script lang="ts">
export default {
  name: 'SingleBarChart',
}
</script>

<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import * as echarts from 'echarts'

const singleBar = ref()
onMounted(() => {
  const myChart = echarts.init(singleBar.value)
  const option = {
    tooltip: {
      trigger: 'axis',
    },

    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      data: ['进度'],
      show: false,
    },
    series: {
      type: 'bar',
      data: [30],
      barWidth: 10,
      showBackground: true,
      label: {
        show: true,
        formatter: '|',
        color: 'yellowgreen',
        offset: [50, 0],
      },
      itemStyle: {
        color: 'yellowgreen',
      },
    },
  }
  myChart.setOption(option)
  window.addEventListener('resize', () => {
    myChart.resize()
  })
})
</script>

<style scoped>
.single-bar {
  width: 100%;
  height: 100%;
}
</style>
